<?php

namespace App\Http\Resources\App;

use Illuminate\Http\Resources\Json\JsonResource;

class UserProfileResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        return ['name' => $this->name, 'career_name' => $this->careers[0]->title ?? null, 'career_id' => $this->careers[0]->id ?? null, 'latest_complete_course' => new CourseResource($this->courses[0] ?? []), 'exp' => $this->profile->exp??0, 'depth' => $this->profile->depth??0, 'learn_courses_count' => $this->courses_count, 'learn_count' => $this->learnCourseCount()];
    }
}
